<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>发现-详情</title>
    <link rel="stylesheet" href="../css/initialize.css">
    <link rel="stylesheet" href="../css/F_index.css?v=201710241606">
</head>
<body>

<div class="F-box">

    <div class="F-imgtop_box">
        <img id="F-ajax_url" src="" alt="">
    </div>

    <div class="F-text_box">
        <h1 id="F-ajax_title"></h1>
        <div id="F-ajax_index">
        </div>

        <div class="F-p_text_tab">
            <p class="F-text_tab"><span id="F-ajax_span"></span><img class="F-img_cor" src="../image/below_cor.png" alt=""></p>
        </div>

        <div class="F-box_style">
        </div>

        <div class="F-commodity">
            <div id="F-ajax_commodity">
            </div>
        </div>
    </div>

</div>

<script src="../js/rem.js"></script>
<script src="../js/Url.js"></script>
<script src="../js/jquery-2.2.4.min.js"></script>
</body>
</html>

<script type="application/javascript">

    APP_H5invoking(OrderId)

    function APP_H5invoking(id) {

        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

        $.ajax({
            type: "get",
            async:false,
			dataType : "jsonp",//数据类型为jsonp  
			jsonp: "jsonpCallback",//服务端用于接收callback调用的function名的参数
            url: ObjUrl.URLdata + '/html/topicDetail?topicId=' + id,
            success: function (data) {
                var datas = data.data;
                var change = datas.content.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
                console.log(datas)
                $("#F-ajax_url").attr('src', ObjUrl.URLimgs + "/restful/file/downloadthumb?fileId=" + datas.coverImage);
                $("#F-ajax_index").html(change)
                $("#F-ajax_title").html(datas.title)
                $("#F-ajax_span").html(datas.goodsTitle)
                var commodityHtml = "";
                var uldHtml = "";
                for (var i = 0; i < datas.goodsList.length; i++) {
                    var dataHtml = datas.goodsList[i];
                    if (dataHtml.dataType == "1") {
                        commodityHtml +=
                                '<div class="F-box_commod fl F-click" data-typeid="' + dataHtml.dataType + '" data-id="' + dataHtml.dataId + '">' +
                                '<p class="F-imgp"><a href="javascript:;"><img class="F-img_commod_sum" src="' + ObjUrl.URLimgs + '/restful/file/downloadthumb?fileId=' + dataHtml.coverImage+'&h=250&w=250" alt=""></a></p>' +
                                '<p>' + dataHtml.goodsName + '</p>' +
                                '<p>批发价 <span class="F-price_color">¥' + dataHtml.goodsPrice + '</span></p>' +
                                '</div>';
                    } else {
                        uldHtml +=
                                '<p class="F-click" data-typeid="' + dataHtml.dataType + '" data-id="' + dataHtml.dataId + '"><a href="javascript:;"><img class="F-img_style" src="' + ObjUrl.URLimgs + '/restful/file/downloadthumb?fileId=' + dataHtml.coverImage +'" alt=""></a></p>' +
                                '<div class="F-label">' +
                                '<p class="F-p_lh"><span class="F-span_color">风格标签：</span>' + dataHtml.groupStyle + '</p>' +
                                '<p class="F-p_lh">适合场景：' + dataHtml.groupScene + '</p>' +
                                '<p class="F-p_lh"><span class="F-span_color">适合群体：</span>' + dataHtml.groupCustomer + '</p>' +
                                '</div>';
                    }
                }

                $("#F-ajax_commodity").html(commodityHtml)
                $(".F-box_style").html(uldHtml)

                $(".F-box_commod").each(function (i, val) {
                    i += 1;
                    if (i % 2 == 0) {
                        $(this).removeClass("fl");
                        $(this).addClass("fr");
                    }
                })

                $(".F-click").click(function (e) {
                    var dataId = $(this).data("id");
                    var typeId = $(this).data("typeid");

                    var APP_obj = {
                        id: dataId,
                        type: typeId
                    }
                    if (isiOS) {
                        window.webkit.messageHandlers.AppModel.postMessage(APP_obj);
                    } else {
                        window.AppModel.postMessage(dataId,typeId);
                    }
                });
            }
        })
    }

</script>
